<?php
session_start();
if(!isset($_SESSION['uid']))
 	{?>
		<script type="text/javascript">
			window.location="error.php";
		</script>
	<?php
 	}else
 		{
			include_once 'topStaticBar.php';		  		
	?>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<h1 align="center">View Vehicle Information</h1>
	<table border="1" align="center">
		<th align="center">Stock_ID</th>
		<th align="center">Make</th>
		<th align="center">Status</th>	
		<th align="center">Image</th>		
		<th align="center">Details</th>
		<th align="center">Vehicle Overview</th>
		<th align="center">Mechanical</th>
		<th align="center">Exterior</th>
		<th align="center">Interior</th>
		<th align="center">EPA Fuel Economy</th>
		<th align="center">Safety</th>
		<th align="center">Additional Features</th>
		<th align="center">Vehicle Condition</th>
		<th align="center">Add Main Image</th>		
		<?php 		
            include_once 'dataBaseConnectivityFile.php';
            $sql_get=mysql_query("SELECT stock.STOCK_ID, stock.MAKE, stock.`CONDITION`, stock.`STATUS`, stock.IMAGE_PATH from stock order by STOCK_ID desc");
            while ($db_field=mysql_fetch_assoc($sql_get))
                {
                    $get_id=$db_field["STOCK_ID"];
                    $get_make=$db_field["MAKE"];
                    $get_status=$db_field["STATUS"];
                    $get_image=$db_field["IMAGE_PATH"];
                    
         ?>                 	
 			    <tr align="center">
			        <td><?php echo $get_id    ?></td>
			        <td><?php echo $get_make  ?></td>
			        <td><?php echo $get_status  ?></td>
			        <td><img src="<?php echo $get_image ?>" width="150px" height="75px"></td>
        	        <td><a href="viewDetails.php?stock_id=<?php echo $get_id?>">View/Edit/Delete</a></td>
                    <td><a href="overviewDetails.php?stock_id=<?php echo $get_id?>">Add</a></td>		        	        		
        	        <td><a href="mechanicalDetails.php?stock_id=<?php echo $get_id?>">Add</a></td>
        	        <td><a href="exteriorDetails.php?stock_id=<?php echo $get_id?>">Add</a></td>
        	        <td><a href="interiorDetails.php?stock_id=<?php echo $get_id?>">Add</a></td>
        	        <td><a href="epaFuelDetails.php?stock_id=<?php echo $get_id?>">Add</a></td>
        	        <td><a href="safetyDetails.php?stock_id=<?php echo $get_id?>">Add</a></td>
        	        <td><a href="additionalDetails.php?stock_id=<?php echo $get_id?>">Add</a></td>
        	        <td><a href="conditionDetails.php?stock_id=<?php echo $get_id?>">Add</a></td>
        	        <?php
        	        	if($get_image =="")
        	        	{
                	?>
 			       	        <td><a href="addImage.php?stock_id=<?php echo $get_id?>">Add Image</a></td>        	                	        		
        	        <?php	
        	        	}
        	        else
        	        {?>
        	        	<td><h3 style=color:gray>Image Already Added</h3></td>
        	         
        	        <?php
        	        } 
        	        ?>

        		</tr>
<?php
 				}
?>		
	</table>
<?php 
 		}
?>